
package com.lmx.persistence.service;

import java.util.List;

import com.lmx.repoDomain.tmodel.UserPrivate;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


/**
 * #{description}
 * 后台登录接口
 * @author shen
 * @version 1.00
 */
@Service
@Scope("prototype")
public class LoginService<T>{
	
	private Log logger = LogFactory.getLog(this.getClass());

    @PersistenceContext
    private EntityManager em;
    
    @Autowired
    protected GenericService dslJpaService;
    
    @Autowired
    protected CommonService commonService;

    /**
     * 获取后台管理用户信息
     * @return
     */
    public UserPrivate getUserInfo(UserPrivate user){
    	
		logger.debug("获取后台管理用户信息");
		String loginName = user.getLoginName();
		
		List result = this.em.createQuery("select u from UserPrivate u ,Role r where u.role.id = r.id and u.status = 3 and u.delStatus != 1 and u.loginName = ?1")
				.setParameter(1, loginName)
				.getResultList();
		UserPrivate resultUser = new UserPrivate();
		if(result.size()>0){
			resultUser = (UserPrivate) result.get(0);
		}
		
        return resultUser;
    }
}
